package DBHelper;

import java.sql.SQLException;

public class ObjectFactory {
    public static void createObject(DBObject o) throws SQLException {
        String query = null;
        if (o.getDescription() == null) {
            query = "insert into objects(name, parent_id, object_type_id) \n" +
                    "values('"+o.getName()+"', "+o.getParentId()+", "+o.getObjectTypeId()+")";
        }
        else {
            query = "insert into objects(name, parent_id, object_type_id, description) \n" +
                    "values('"+o.getName()+"', "+o.getParentId()+", "+o.getObjectTypeId()+", '"+o.getDescription()+"')";
        }
        
        DBHelper.updateQuery(query);
    }
}
